package com.ganxiang.ximenhong.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

import com.ganxiang.ximenhong.R;
import com.ganxiang.ximenhong.base.BaseFragment;

/**
 * Created by Administrator on 2016/9/13 0013.
 */
public class ClassificationFragment extends BaseFragment{

    private View mView;
    private GridView mGv;
    @Override
    public View onCreateView(LayoutInflater inflater,ViewGroup container, Bundle savedInstanceState) {
        mView = View.inflate(mActivity, R.layout.fragment_classification, null);
        init();
        return mView;
    }

    private void init() {
        mGv = (GridView) mView.findViewById(R.id.gv);
        mGv.setAdapter(new GvAdapter());
    }
    class GvAdapter extends BaseAdapter{

        private int[] pictures = {R.drawable.bn_jydq,R.drawable.bn_sjsm,R.drawable.bn_bhjj,R.drawable.bn_qddc,R.drawable.bn_myyp,R.drawable.bn_nzcp,R.drawable.bn_bdsh,R.drawable.bn_xyts};

        @Override
        public int getCount() {
            return pictures.length;
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            if(view == null){
                view = View.inflate(mActivity,R.layout.item_iv_gv,null);
            }
            ((ImageView)view.findViewById(R.id.iv)).setImageResource(pictures[i]);
            return view;
        }
    }
}
